package top.wshape1.rpc.common.exception;

import top.wshape1.rpc.common.constant.RpcMessageCodeEnum;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-02-02
 */

public class RpcException extends RuntimeException {

    private RpcMessageCodeEnum codeEnum;

    public RpcException(Throwable cause) {
        super(cause);
    }

    public RpcException(String message) {
        super(message);
    }

    public RpcException(String message, Throwable cause) {
        super(message, cause);
    }

    public RpcException(RpcMessageCodeEnum codeEnum) {
        super(codeEnum.getMsg());
        this.codeEnum = codeEnum;
    }

    public RpcException(RpcMessageCodeEnum codeEnum, String message) {
        super(codeEnum.getMsg() + ":" + message);
        this.codeEnum = codeEnum;
    }

    public int getCode() {
        return codeEnum.getCode();
    }

}
